<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<script type="text/javascript">
$(function(){
	//初始化表单验证
	$("#addForm").validate({
		submitHandler:function(form){
			$(form).ajaxSubmit({
				success:function(data){
					switch(data.flag){
					/* case -1:
						Kit.alert("网络繁忙...，请重试");return;  */
					case  -1:
						window.location.reload();
						addDialog.close();
						return;
					}
				}
			});
		}
	});
}); 
/* 点击新增规格选项 */ 
$(document).ready(function(){
    $("#addSpec").click(function(){
    	var tr="<tr><td><input class=\"form-control\" name=\"optionName\" placeholder=\"规格参数\">"+
			"</td><td><input type=\"checkbox\" name=\"check\" checked=\"checked\" />"+
			"</td></tr>";
			$("#table").append(tr);
    });
    $("#deleteSpec").click(function(){
        var check = document.getElementsByName("check");
        for(var i=0;i<check.length;i++){
            if(check[i].checked){
                 document.getElementById('table').deleteRow(i);
                 i--;
            }
        }
    });
})
$(function () {
	//全选或全不选
	$("#all").click(function(){   
    	if(this.checked){   
        	$("#table :checkbox").prop("checked", true);  
    	}else{   
		    $("#table :checkbox").prop("checked", false);
    	}   
 	}); 
});
</script>
<form id="addForm" action="${BASE_PATH}/bus/goods/spec/doAdd" method="post" class="form-horizontal" style="">
	<!-- 编辑窗口 -->	
		<div class="form-group"  style="margin-left: 20px">	
			<table class="table table-bordered table-striped">
				<tr>
					<td>规格名称</td>
					<td><input class="form-control" type="text" name="specName"  size="12" placeholder="规格名称" /></td>
				</tr>
			</table>
		</div>
		<div class="form-group"  style="margin-left: 20px">	
			规格操作
			<div class="btn-group">
				<button type="button" class="btn btn-default" title="新建" id="addSpec">
					<i class="fa fa-file-o"></i> 新增规格选项
				</button>
				<button type="button" class="btn btn-default" title="删除" id="deleteSpec">
					<i class="fa fa-file-o"></i> 删除规格选项
				</button>
			</div>
		</div>
		<div class="form-group"  style="margin-left: 20px">	
			<table
				class="table table-bordered table-striped table-hover dataTable">
				<thead>
					<tr>
						<th class="sorting">规格参数</th>
						<th class="sorting">全选<input type="checkbox" name="all" id="all" οnclick=all></th>
				</thead>
				<tbody id="table">
					<tr>
						<td><input class="form-control" type="text" name="optionName" id="optionName" size="12" placeholder="规格参数"></td>
						<td><input type="checkbox" name="check" checked="checked" /></td>
					</tr>
				</tbody>
			</table>
		</div>
		<div class="row">
		<div class="col-lg-6"><button class="btn btn-primary col-sm-3 pull-right" type="submit" autocomplete="off" >提交</button></div>
		<div class="col-lg-6"><button class="btn btn-default col-sm-3 pull-left"  type="button" onclick="javascript:addDialog.close();" autocomplete="off">取消</button></div>
	</div>
</form>
